from tortoise.query_utils import Q

from common.base import Dao
from models.user import User


class UserDao(Dao):

    async def has_user(self, username: str, mobile: str):
        return await self.model.filter(Q(username=username) | Q(mobile=mobile)).first().values()

    async def update_field(self, pk: int, **kwargs):
        return await self.model.filter(pk=pk).update(**kwargs)


user_dao = UserDao(User)

__all__ = ["user_dao"]
